﻿@using Orchard.ContentManagement
@using Orchard.MediaLibrary.Models
@using Orchard.Utility.Extensions
@using System.Text.RegularExpressions;
@model dynamic
           
@{
    ContentItem contentItem = Model.ContentItem;
    var media = contentItem.As<MediaPart>();
    var oembed = contentItem.As<OEmbedPart>();
    string thumbnail = oembed["thumbnail_url"] ?? oembed["thumbnail"];
}

@if (!string.IsNullOrEmpty(thumbnail)) {
    <div class="media-thumbnail media-thumbnail-@contentItem.ContentType.HtmlClassify() mime-type-@media.MimeType.HtmlClassify()">
        <img src="@thumbnail" style="width:200px"/>
        @*<img src="@Display.ResizeMediaUrl(Width: 200, Height: 200, Mode: "crop", Alignment: "middlecenter", Path: thumbnail)" />*@
    </div>
}
else if(!string.IsNullOrEmpty(oembed["html"])) {
    <div class="media-thumbnail media-thumbnail-@contentItem.ContentType.HtmlClassify() mime-type-@media.MimeType.HtmlClassify()">
        @Html.Raw(Regex.Replace(oembed["html"], "<script.*?>.*?</script>", "", RegexOptions.IgnoreCase))
    </div>
}